const btn=document.querySelector('#btnChoose')
const input=document.querySelector('#iptFile')
const img=document.querySelector('.thumb')

btn.addEventListener('click', function () {
  input.click()
})

input.addEventListener('change',async function (){
  const formdata = new FormData()
  if (!this.files[0]) return alert('加照片')
  formdata.append('avatar', this.files[0])
const {data:res}=await axios.post('http://ajax-api.itheima.net/api/file',formdata)
  const url = res.data.url
  img.src=url
})